Imports System.Data.OleDb

Public NotInheritable Class FileDB

    Private Const FileIDsSelectSQL As String = "SELECT file_id FROM Files WHERE provider = '{0}' AND code = '{1}'"

    Private Sub New()

    End Sub

    Public Shared Function GetFileIDsForProviderProductCode(ByVal provider As String, _
                                                            ByVal productCode As String) As Integer()

        Dim conn As New OleDbConnection
        Dim idList As New ArrayList

        Try

            conn.ConnectionString = My.Settings.PoserFilesConnectionString
            conn.Open()

            Dim cm As New OleDbCommand
            cm.Connection = conn
            cm.CommandType = CommandType.Text
            cm.CommandText = String.Format(FileIDsSelectSQL, _
                                           provider, _
                                           productCode)

            Dim results As OleDbDataReader = cm.ExecuteReader

            While results.Read
                idList.Add(CType(results(0), Integer))
            End While

        Catch ex As Exception
            MsgBox(ex.Message)
            If conn.State <> ConnectionState.Closed Then
                conn.Close()
            End If
        End Try

        Return CType(DirectCast(idList.ToArray(GetType(Integer)), Integer()), Integer())

    End Function

End Class
